import threading
import socket

def In(s):
    while 1:
        inString = s.recv(1024).decode('utf-8')
        print(inString)

def Out(s):
    while 1:
        outString = input()
        s.send(outString.encode('utf-8'))

HOST='127.0.0.1'
PORT=1315
nick = input('your name>')
s = socket.socket(socket.AF_INET,socket.SOCK_STREAM)
s.connect((HOST,PORT))
s.send(nick.encode('utf-8'))

threading.Thread(target=In,args=(s,)).start()
threading.Thread(target=Out,args=(s,)).start()

